import java.util.TreeSet;
import java.util.Iterator;
import java.util.Scanner;

public class HomeWork18_01{
    public static void main(String[] args){
        Game g = new Game();
        g.execute();
    }
}

class Game{
    private TreeSet<Prize> tSet;
    private Scanner scan;
    private int guessTime = 10;         //10次猜测机会
    private int remainIndex = 10;       //剩余奖品数量
    private int cusPoints = 0;          //玩家的积分
    
    private String[] pArr = new String[]{
        "25", "30", "55", "60", "15",
        "45", "50", "20", "35", "40"  
    };
    
    public Game(){
        tSet = new TreeSet<Prize>();
        scan = new Scanner(System.in);
        
        for(int i = 0; i < 10; i++){
            tSet.add(new Prize(i + 1, pArr[i]));
        }   
    }
    
    public void execute(){
         while(guessTime-- > 0 && cusPoints < 100){
            //打印所有奖品id以及每个奖品的积分点
            printAllPrize();
            
            System.out.print("说出你猜测转轮所转到奖品的id: ");
            int n = scan.nextInt();
            
            //判断猜测的数字与随机生成的数字是否相同
            if(checkGuessNumb(n)){
                //猜测正确，获得积分，并在转轮中删除当前奖品
                System.out.print("恭喜你猜对了!");
            }else{
                System.out.print("很遗憾，你猜错了.");
            }
            
            System.out.println("你的积分: " + cusPoints + "\n");
        }//while
        
        if(isWin()){
            System.out.println("获胜");
        }else{
            System.out.println("失败");
        }
    }
    
    private void printAllPrize(){
        System.out.println("所有奖品: ");
        Iterator<Prize> iter = tSet.iterator();
        for(int i = 1; i <= remainIndex; i++){
            System.out.println("id: " + i + " " + iter.next());
        }
    }
    
    private boolean checkGuessNumb(int n){
        int radm = (int)(Math.random()*remainIndex + 1);
        if(radm == n){
            //猜测正确，获得积分，并在转轮中删除当前奖品
            remainIndex--;
            Iterator<Prize> iter = tSet.iterator();
            iter = tSet.iterator();
            for(int i = 0; i < n - 1; i++){
                iter.next();
            } 
            Prize tmp = iter.next();
            cusPoints += Integer.parseInt(tmp.points);
            tSet.remove(tmp);
            
            return true;
        }
        
        return false;
    }
    
    private boolean isWin(){
        return cusPoints >= 100;
    }
}

class Prize implements Comparable<Prize>{
    int id;
    String points;
    
    public Prize(int id, String points){
        this.id = id;
        this.points = points;
    }
    
    public int compareTo(Prize p){
        return this.id - p.id;
    }
    
    public String toString(){
        return "[ points: " + points + " ]";
    }
}